package com.mdp.im.core.publish.action;

import com.mdp.im.core.publish.action.impl.*;
import com.mdp.im.core.publish.action.impl.*;
import com.mdp.im.core.publish.api.action.PublishAction;
import com.mdp.im.core.utils.msg.Action;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 消息处理器工厂类
 * 
 * @author chenyc
 * @date 2020/3/29
 */
@Service
public class PublishActionFactory {

	@Autowired
    OnlineStatusChangedAction onlineStatusChangedAction;
	@Autowired
    NicknameChangedAction nicknameChangedAction;
	@Autowired
    AvatarChangedAction avatarChangedAction;
	@Autowired
    NewMessageAction newMessageAction;
	@Autowired
    HisMessageAction hisMessageAction;
	@Autowired
    ChannelGroupCreatedAction channelCreatedAction;
	@Autowired
    JoinChannelGroupAction joinGroupAction;
	@Autowired
    RemoveMessageAction removeMessageAction;
	@Autowired
    ChannelGroupNameChangedAction channelNameChangedAction;
	@Autowired
    MembersCountChangedAction membersCountChangedAction;
	@Autowired
    LeaveChannelGroupAction leaveGroupAction;
	@Autowired
    ChannelGroupRemoveAction channelRemoveAction;
	@Autowired
    ListMyPrichatChannelGroupsAction listMyPrichatChannelGroupsAction;
	@Autowired
    MessageStateReportAction messageStateReportAction;
    /**
     * 创建消息处理器
     * 
     * @param action
     * @return
     */
    public PublishAction getPushAction(String action) {
        switch (action) {
        case Action.ONLINE_STATUS_CHANGED:
            return onlineStatusChangedAction;
        case Action.NICKNAME_CHANGED:
            return nicknameChangedAction;
        case Action.AVATAR_CHANGED:
            return avatarChangedAction;
        case Action.NEW_MESSAGE:
            return newMessageAction;
        case Action.HIS_MESSAGE:
            return hisMessageAction;
        case Action.CHANNEL_GROUP_CREATE:
            return channelCreatedAction;
        case Action.JOIN_CHANNEL_GROUP:
            return joinGroupAction;
        case Action.MESSAGE_REMOVED:
            return removeMessageAction;
        case Action.CHANNEL_GROUP_NAME_CHANGED:
            return channelNameChangedAction;
        case Action.MEMBERS_COUNT_CHANGED:
            return membersCountChangedAction;
        case Action.LEAVE_CHANNEL_GROUP:
            return leaveGroupAction;
        case Action.CHANNEL_GROUP_REMOVE:
            return channelRemoveAction;
        case Action.LIST_MY_PRICHAT_CHANNEL_GROUPS:
	        return listMyPrichatChannelGroupsAction;
	    case Action.MESSAGE_STATE_REPORT:
	        return messageStateReportAction;
        }
        return null;
    }

}
